package com.kyrioscraft.cloud.common.exception;

import com.kyrioscraft.cloud.common.vo.RestResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    @ResponseBody
    public RestResponse allExceptionHandler(HttpServletRequest request,
                                            Exception exception) {
        return RestResponse.fail(exception.getMessage());
    }

}
